package com.bbm.controller;


import com.bbm.entity.Category;
import com.bbm.entity.vo.ResponseResult;
import com.bbm.service.CategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Category)表控制层
 *
 * @author lionkliu
 * @since 2024-02-18 15:06:04
 */
@RestController
@RequestMapping("category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    @GetMapping("/list")
    public ResponseResult getAll() {
        return categoryService.list();
    }

    @PostMapping
    public ResponseResult insert(@RequestBody Category category) {
        return categoryService.insertOne(category);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Category category) {
        return categoryService.updateOne(category);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return categoryService.deleteById(id);
    }

}
